
#ifndef _MAINWINDOW_H_
#define _MAINWINDOW_H_

#include <BLineEdit>
#include <BTextEdit>
#include <BLabel>
#include <BButton>
#include <BScrollArea>
#include <BScrollWidget>
#include <BListWidget>
#include <BListItem>
#include <BProgressBar>
#include <BComboBox>
#include <BTableWidget>
#include <BTableItem>
#include <BScrollWidget>
#include <BScrollBar>
#include <BTreeWidget>
#include <BHtmlWidget>
#include <BStyle>
#include <BGridLayout>
#include <BHBoxLayout>
#include <BVBoxLayout>
#include <BGroupBox>
#include <BXmlNode>
#include <BSonNode>
#include <BMenu>
#include <BMainWindow>

#include "StyleEdit.h"

using namespace BWE;

class MainWindow : public BMainWindow
{
public:
	MainWindow();
	~MainWindow();

protected:
	BTreeItem* createTreeItem(BXmlNode* node);
	BTreeItem* createTreeItem(BSonNode* node);
	bool assignIcon(BTreeItem* item);
	BTreeItem* createTreeItem(BStyle* style);

	BString sroleToString(StyleRole srole);
	BString valueToString(const BValue& value);

protected:
	void slotFileButtonClicked(BObject* object);
	void slotLoadButtonClicked();

	void slotItemDoubleClicked(BObject* object, const BValue& value);
	void slotItemTextEdited(BObject* object, const BValue& value);
	void slotItemTextEditFocusOut(BObject* object);
	void slotPolicyButtonClicked(BObject* object, const BValue& value);
	void slotPolicyMenuTrigger(BObject* object, const BValue& value);

	void slotSheetFileNameEdited();
	void slotBrowseFileButtonClicked();
	void slotSaveSheetButtonClicked();
	void slotStyleSheetEdited(BObject* object, const BValue& value);
	void slotTreeItemSelected(BObject* object, const BValue& value);

protected:
	virtual void styleEvent(const BEvent& event);

private:
	BLineEdit*		_fileNameEdit;
	BButton*		_browseFileButton;
	BButton*		_loadFileButton;
	BButton*		_saveFileButton;
	BTreeWidget*	_treeWidget;
	StyleEdit*		_styleSheetEdit;
	BTableWidget*	_tableWidget;

	BIconHolder		_rootIcon;
	BIconHolder		_subsIcon;
	BIconHolder		_itemIcon;
};

#endif